#ifndef UFO_H
#define UFO_H

#include <cstdlib>

#include <QObject>
#include <QQueue>
#include <QTimer>
#include <QVector3D>

#include "ai/path.h"
#include "entity/entity.h"
#include "geometry/sphere.h"

class QVector3D;

class Cow;
class Object;

class UFO : public QObject, public Entity
{
    Q_OBJECT

public:
    typedef enum
    {
        Loading,
        Unloading
    } State;

    explicit UFO(QObject* pkParent = NULL);
    ~UFO();

    static Object& object();

    qreal velocity() const;
    Path& path();

    bool isTeleportReady() const;

    Sphere body() const;
    QVector3D position() const;
    qreal teleportRadius() const;
    qreal teleportVelocity() const;
    Cow& loadedCow(quint8 uiIndex) const;

    void setPosition(const QVector3D& rkPosition);
    void setPosition(qreal x, qreal y, qreal z);

    State state() const;
    void setState(State eState);

    bool isEmpty() const;
    bool isFull() const;
    void load(Cow& rkCow);
    Cow& unload();
    void clear();

public slots:
    void fire();
    void reload();

protected:
    UFO(const UFO&);
    UFO& operator = (const UFO&);

private:
    //------------------------------------------------
    //  Attributes.
    //------------------------------------------------
    // Visual.
    static Object* s_pkUFOObject;

    // Motion.
    qreal          m_velocity;
    Path           m_kPath;

    // UFO state.
    State          m_eState;

    // Teleport.
    qreal          m_teleportRadius;
    qreal          m_teleportVelocity;

    bool           m_bIsTeleportReady;
    QTimer         m_kReloadTimer;
    quint32        m_uiTeleportReloadDelay;

    QQueue< Cow* > m_kLoadedCows;
};

#endif // UFO_H
